home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / wgdb-42.lha / wgdb-4.2 / gdb / nindy-share / ttybreak.c < prev    next >
C/C++ Source or Header  |  1992-09-11  |  2KB  |  79 lines

  1. /*****************************************************************************
  2.  *         Copyright (c) 1990, Intel Corporation
  3.  *
  4.  * Intel hereby grants you permission to copy, modify, and 
  5.  * distribute this software and its documentation.  Intel grants
  6.  * this permission provided that the above copyright notice 
  7.  * appears in all copies and that both the copyright notice and
  8.  * this permission notice appear in supporting documentation.  In
  9.  * addition, Intel grants this permission provided that you
  10.  * prominently mark as not part of the original any modifications
  11.  * made to this software or documentation, and that the name of 
  12.  * Intel Corporation not be used in advertising or publicity 
  13.  * pertaining to distribution of the software or the documentation 
  14.  * without specific, written prior permission.  
  15.  *
  16.  * Intel Corporation does not warrant, guarantee or make any 
  17.  * representations regarding the use of, or the results of the use
  18.  * of, the software and documentation in terms of correctness, 
  19.  * accuracy, reliability, currentness, or otherwise; and you rely
  20.  * on the software, documentation and results solely at your own risk.
  21.  *****************************************************************************/
  22.  
  23. static char rcsid[] =
  24.     "$Id";
  25.  
  26.  
  27. /******************************************************************************
  28.  * send_break:
  29.  *
  30.  *    This function sends a a "break" to the specified tty.  This is useful
  31.  *    if the tty is attached to an i960 board equipped with a break-detector
  32.  *    circuit that causes a hard reset of the board.
  33.  ******************************************************************************/
  34.  
  35. #include <stdio.h>
  36. #include "ttycntl.h"
  37.  
  38. #ifdef USG
  39.     send_break( fd )
  40.         int fd;    /* File descriptor of i960 tty */
  41.     {
  42.         TTY_FLUSH(fd);
  43.         ioctl( fd, TCSBRK, 0 );
  44.     }
  45.  
  46. #else    /* BSD Unix */
  47.  
  48. #    include <signal.h>
  49. #    include <sys/time.h>
  50.  
  51.     static void
  52.     alarm_handler()
  53.     {
  54.         return;
  55.     }
  56.  
  57.     send_break( fd )
  58.         int fd;    /* File descriptor of i960 tty */
  59.     {
  60.         struct itimerval t;
  61.         void (*old_alarm)();    /* Alarm signal handler on entry */
  62.  
  63.         old_alarm = signal( SIGALRM, alarm_handler );
  64.  
  65.         /* Set timer for 1/4 second break */
  66.         t.it_value.tv_sec = 0;
  67.         t.it_value.tv_usec = 250000;
  68.         t.it_interval.tv_sec = t.it_interval.tv_usec = 0;
  69.  
  70.         /* Assert break for the duration of the timer */
  71.         ioctl( fd, TIOCSBRK, 0 );
  72.         setitimer( ITIMER_REAL, &t, 0 );
  73.         sigpause(0);
  74.         ioctl( fd, TIOCCBRK, 0 );
  75.  
  76.         signal( SIGALRM, old_alarm );
  77.     }
  78. #endif
  79.